#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project    :icac2 
@File       :get_fields.py
@Author     :wangfan13
@Date       :2021/5/28 14:43 
"""
def getsettlecode(param):
    if param.get('settlecode', -1) == -1 or param.get('settlecode', -1) == '':
        return ''
    else:
        if 'settlecode' in param.keys():
            return ' and settlecode = \'' + param.get('settlecode') + '\''


def getsettleowner(param):
    if param.get('settleowner', -1) == -1 or  param.get('settleowner', -1) == '':
        return ''
    else:
        if 'settleowner' in param.keys():
            return ' and settleowner = \'' + param.get('settleowner') + '\''


def getordercode(param):
    if param.get('ordercode', -1) == -1 or param.get('ordercode', -1) == '':
        return ''
    else:
        if 'ordercode' in param.keys():
            return ' and ordercode = \'' + param.get('ordercode') + '\''


def getstat(param):
    if param.get('stat', -1) == -1 or param.get('stat', -1) == '':
        return ''
    else:
        if 'stat' in param.keys():
            return ' and stat = \'' + param.get('stat') + '\''


def getyear(param):
    if (param.get('date', -1) == -1 and param.get('season', -1) == -1) or (param.get('date', -1) == '' and param.get('season', -1) == ''):
        return ''
    if param.get('date', -1) != -1 and param.get('season', -1) == -1 or param.get('season', -1) == '':
        return ' and year(submitdate) = ' + str(param.get('date'))
    else:
        return ' and getseason(submitdate) = CONCAT(' + str(param.get('date')) + "," + str(param.get('season')) + ")"


def getpage(param):
    if param.get('page_size', -1) == -1 or param.get('page_num', -1) == -1:
        return ''
    else:
        return ' limit ' + str(param.get('page_num')) + "," + str(param.get('page_size'))


def getsettlecode_cheat(param):
    if param.get('settlecode', -1) == -1 or param.get('settlecode', -1) == '':
        return ''
    else:
        if 'settlecode' in param.keys():
            return ' and 结算案编号 = \'' + param.get('settlecode') + '\''


def getsettleowner_cheat(param):
    if param.get('settleowner', -1) == -1 or param.get('settleowner', -1) == '':
        return ''
    else:
        if 'settleowner' in param.keys():
            return ' and 政策解释人 = \'' + param.get('settleowner') + '\''


def getordercode_cheat(param):
    if param.get('ordercode', -1) == -1 or param.get('ordercode', -1) == '':
        return ''
    else:
        if 'ordercode' in param.keys():
            return ' and 订单SO = \'' + param.get('ordercode') + '\''


def getyear_cheat(param):
    if param.get('date', -1) == -1 and param.get('season', -1) == -1 or (param.get('date', -1) == '' and param.get('season', -1) == ''):
        return ''
    if param.get('date', -1) != -1 and param.get('season', -1) == -1 or param.get('season', -1) == '':
        return ' and year(策划案提交时间) = ' + str(param.get('date'))
    else:
        return ' and getseason(策划案提交时间) = CONCAT(' + str(param.get('date')) + "," + str(param.get('season')) + ")"
